//package com.bestcem.xm.user.grpc.client;
//
//import io.grpc.CallCredentials;
//import io.grpc.Metadata;
//import io.grpc.Status;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Service;
//
//import java.util.concurrent.Executor;
//
//import static io.grpc.Metadata.ASCII_STRING_MARSHALLER;
//
///**
// * ip服务 token
// *
// * @author wangyunyun <yunyun.wang@idiaoyan.com>
// * @version v1.0
// * @date 2022/3/1 14:30
// **/
//@Service
//public class TokenCallCredentials extends CallCredentials {
//    @Value("${grpcService.ip.appKey}")
//    private String appKey;
//
//    @Value("${grpcService.ip.appSecret}")
//    private String appSecret;
//
//    @Override
//    public void applyRequestMetadata(RequestInfo requestInfo, Executor appExecutor, MetadataApplier applier) {
//        appExecutor.execute(() -> {
//            try {
//                Metadata headers = new Metadata();
//                headers.put(Metadata.Key.of("app_key", ASCII_STRING_MARSHALLER), appKey);
//                headers.put(Metadata.Key.of("app_secret", ASCII_STRING_MARSHALLER), appSecret);
//
//                applier.apply(headers);
//            } catch (Throwable e) {
//                applier.fail(Status.UNAUTHENTICATED.withCause(e));
//            }
//        });
//    }
//
//    @Override
//    public void thisUsesUnstableApi() {
//
//    }
//}
